package com.powernode.ssm.controller;

import com.powernode.ssm.pojo.vo.*;
import com.powernode.ssm.pojo.po.*;
import com.powernode.ssm.utils.*;
import com.powernode.ssm.service.EmpService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; 
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;


@Api(
       value ="员工管理",
       tags = {"员工管理"})

@RestController
@RequestMapping("/Emp")
public class EmpController {

   @Autowired
   private EmpService empService;

   @Autowired
   private SpringUtils springUtils;

   @ApiOperation("查询员工管理")
   @RequestMapping(value = "/B109801",method = RequestMethod.POST)
   public ResponseUtils queryEmp(@Validated @RequestBody QueryEmpVo queryEmpVo){
       return empService.queryEmp(queryEmpVo);
   }

   @ApiOperation("増加员工管理")
   @RequestMapping(value = "/B109802",method = RequestMethod.POST)
   public ResponseUtils saveEmp (@Validated @RequestBody SaveEmpVo saveEmpVo){

        return empService.saveEmp(saveEmpVo);
}

   @ApiOperation("更新员工管理") 
   @RequestMapping(value = "/B109803",method = RequestMethod.POST)
   public ResponseUtils updateEmp(@Validated @RequestBody UpdateEmpVo updateEmpVo){
       return empService.updateEmp(updateEmpVo);
   }

   @ApiOperation("批量删除员工管理")
   @RequestMapping(value = "B109804",method = RequestMethod.POST)
   public ResponseUtils batchDeleteEmp(@Validated @RequestBody DeleteEmpVo deleteEmpVo){
       return empService.batchDeleteEmp(deleteEmpVo);
   }

   @ApiOperation("easyExcel导出员工管理")
   @RequestMapping(value = "B109805",method = RequestMethod.POST)
   public ResponseUtils exportEmp (HttpServletResponse httpServletResponse,
                                   @Validated @RequestBody QueryEmpVo queryEmpVo){
       H5UserinfoPo h5UserinfoPo = springUtils.getUserByToken(ThreadLocalContext.getToken());
       return empService.exportEasyExcelWithTemplate(httpServletResponse,h5UserinfoPo, queryEmpVo) ;
   }

   @ApiOperation("easyExcel导入员工管理")
   @RequestMapping(value = "B109806",method = RequestMethod.POST)
   public ResponseUtils importEmp (@Validated ImportEmpVo importEmpVo){
       H5UserinfoPo h5UserinfoPo = springUtils.getUserByToken(ThreadLocalContext.getToken());
       return empService.importEasyExcelWithTemplate(importEmpVo,h5UserinfoPo);
   }

}
